<%@ page language="java" contentType="text/html; charset=utf-8"
         pageEncoding="utf-8" isELIgnored="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>


<%
    String menuPath = request.getContextPath();
    String menuBasePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + menuPath + "/";

%>
<script type="text/javascript">
    var path = "<%=menuBasePath%>";
    var menuId =<%=request.getParameter("menuId") %>;
    $(document).ready(function () {
        $.post(path + "/system/menu/loadMenu.html", function (data) {
            var html = "";
            var smallHtml = '';
            var className = {
                'locationService': 'icon-index',
                'reportCenter': 'icon-data',
                'monitorCenter': 'management'
            };
            $(data.menuList.level_one).each(function (index, one) {
                if (index == 0) {
                    smallHtml += '<li><a class="icon icon_' + index + '" href="' + path + 'index/toIndex.html"></a></li>';
                } else {
                    smallHtml += '<li><a class="icon icon_' + index + '" href="javascript:;"></a></li>';
                }


                var level_two = data.menuList.level_two[one.menuId];
                if (level_two) {
                    var towSize = level_two.length;
                    html += "<li class='sub-menu pr'> "
                    html += "<a class='sub-menu-title'>" + one.menuName + "</a> ";
                    if (towSize > 6) {
                        html += "<span class='icon icon-more pa'></span> ";
                    }
                    html += " <div class='clearfix pr'> ";

                    if (level_two == null) {
                        return true;
                    }

				var count=Math.ceil(towSize/6)-1;
                    if (towSize > 6) {
                        var pageOne = 6;
                    } else {
                        var pageOne = towSize
                    }
                    html += "<ul class='three-menu-ul clearfix fl'>";
                    for (var i = 0; i < pageOne; i++) {
                        //基础数据|系统管理|查岗管理
                        if (one.menuCode == 'baseData' || one.menuCode == 'systemData' || level_two[i].menuCode == 'checkManager') {
                            html += " <li class='three-menu-li fl'><a href='" + path + "system/menu/toContentManager.html?menuId=" + level_two[i].menuId + "' title='" + level_two[i].menuName + "'>" + level_two[i].menuName + "</a></li>";
                        } else {
                            html += " <li class='three-menu-li fl'><a target='_blank' href='" + path + level_two[i].menuUrl + "?menuId=" + level_two[i].menuId + "' title='" + level_two[i].menuName + "'>" + level_two[i].menuName + "</a></li>";
                        }

                    }
                    html += "</ul>";
                    var Surplus = towSize - 6; //每个ul四个菜单，判断最后是否不足4个菜单再新多一个ul
                    if (Surplus > 0) {
                        html += '<ul class="three-menu-ul clearfix three-menu-ul-' + Math.ceil(Surplus / 2) + ' three-menu-ul-hide pa">';
                    }
                    for (var i = 0; i < Surplus; i++) {
                        //基础数据|系统管理|查岗管理
                        if (one.menuCode == 'baseData' || one.menuCode == 'systemData' /*|| level_two[i].menuCode == 'checkManager'*/) {
                            html += " <li class='three-menu-li fl'><a href='" + path + "system/menu/toContentManager.html?menuId=" + level_two[i].menuId + "' title='" + level_two[(count * 6) + i].menuName + "'>" + level_two[(count * 6) + i].menuName + "</a></li>";
                        } else {
                            html += " <li class='three-menu-li fl'><a target='_blank' href='" + path + level_two[6 + i].menuUrl + "?menuId=" + level_two[6 + i].menuId + "' title='" + level_two[6 + i].menuName + "'>" + level_two[6 + i].menuName + "</a></li>";
                        }
                    }
                    if (Surplus > 0) {
                        html += "</ul>";
                    }
                    html += "</div>";
                    html += "</li>";
                };
            });
            $("#menu").html(html);
            $('.small-nav').find('ul').html(smallHtml);
        }, "json");

    });
</script>


<div class="nav-menu pr fl">

    <div class="small-nav">
        <%-- <a class="db smallLogo" href="javascript:;" title=""><img src="<%=menuBasePath%>resources/images/main/smallLogo.png" /></a> --%>
        <ul>
        </ul>
    </div>
    <div class="big-nav pa dn">
        <ul class="menus" id="menu">

        </ul>
        <div class="ewm-warp dn">
            <div class="ewm clearfix">
                <div class="driver list fl" style="display:none;">
                    <%-- <img src="<%=menuBasePath%>resources/images/login/ewm1.png"> --%>
                    <p>司机公众号</p>
                </div>
                <div class="team list fl" style="width:100%;">
                    <%-- <img style="width:50px;height:50px;" src="<%=menuBasePath%>resources/images/login/ewm2.png"> --%>
                    <p>车队APP</p>
                </div>
            </div>
            <p class="text"><span class="tip">扫描二维码</span><span class="sm"></span></p>
        </div>
    </div>
    <div class="mask-nav" id="mask-nav"></div>
</div>
